import {isObject, isString} from 'lodash-es';

const beautifyJson = (val: string | object): string => {
    let input = val;
    try {
        isString(input) && (input = JSON.parse(decodeURIComponent(input)));
        if (isObject(input)) {
            return JSON.stringify(input, null, '\t');
        }
    } catch {
    }
    return input as string;
};

export default beautifyJson;
